

#include "MyButton.h"
#include "MyEngine.h"
#include "MyMenu.h"
#include "MyUniversal.h"

//constr/destr
MyButton::MyButton(SDL_Rect* _box, int _id, MyMenu* _parent){ box = _box; id = _id; parent = _parent; }
MyButton::~MyButton(){
	delete(box);
#ifdef _DEBUG
	printf("destroyed button\n");
#endif
}
//display the button on screen
void MyButton::show()
{
	apply_surface( box->x, box->y, parent->buttonSheet, parent->parent->screen,clip); 
}
//set the button clip
void MyButton::set_clip (SDL_Rect* _clip) {	clip = _clip; };
//checks if the parameters are in the button -- return true if they are
int MyButton::in_me (int _x, int _y)
{ 
  if ((_x > this->box->x) && 
	  (_x < this->box->x+this->box->w) && 
	  (_y > this->box->y) && 
	  (_y < this->box->y+this->box->h)) 
  return this->id;
  else  return 0;
}
//returns the button id
int MyButton::get_id(){return id;};
